/**
 * 
 */
package view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

/**
 * @author Ken
 *
 */
public class AddLinkDialogView extends Dialog {
	/**
	 * @param arg0
	 */
	public AddLinkDialogView(Shell shell, Display display) {
		super(shell);
		this.shell = shell;
		this.display = display;
	}
	
	public void open() {		
		shell.setText("Enter new address to download");
		shell.setImage(new Image(display, "res/app_icon.png"));
		address = new Label(shell, SWT.NONE);
		address.setText("Address");
		address.pack();
		
		addressInput = new Text(shell, SWT.BORDER | SWT.FILL_WINDING);
		GridData inputLayoutData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
		addressInput.setLayoutData(inputLayoutData);
		
		acceptBtn = new Button(shell, SWT.PUSH);
		acceptBtn.setText("OK");
		GridData acceptBtnLayout = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
		acceptBtnLayout.widthHint = 76;
		acceptBtn.setLayoutData(acceptBtnLayout);
		
		authoGroupBox = new Group(shell, SWT.CHECK);
		authoGroupBox.setEnabled(false);
		authoGroupBox.setText("Use authorization");
		GridData groupData = new GridData(SWT.FILL, SWT.CENTER, true, true, 2, 2);
		authoGroupBox.setLayoutData(groupData);
		
		GridLayout gridLayout = new GridLayout(4, false);
		gridLayout.marginWidth = 4;
		gridLayout.marginHeight = 5;
		authoGroupBox.setLayout(gridLayout);
		
		Label login = new Label(authoGroupBox, SWT.NONE);
		login.setText("Login");
		login.setAlignment(SWT.RIGHT);
		GridData loginData = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
		loginData.widthHint = 80;
		login.setLayoutData(loginData);
		
		loginInput = new Text(authoGroupBox, SWT.BORDER);
		GridData loginInputData = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
		loginInputData.widthHint = 120;
		loginInput.setLayoutData(loginInputData);
		
		Label pass = new Label(authoGroupBox, SWT.NONE);
		pass.setText("Password");
		pass.setAlignment(SWT.RIGHT);
		GridData passData = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
		passData.widthHint = 95;
		pass.setLayoutData(passData);
		
		passwdInput = new Text(authoGroupBox, SWT.BORDER);
		GridData passInputData = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
		passInputData.widthHint = 120;
		passwdInput.setLayoutData(passInputData);
		
		for (Control control : authoGroupBox.getChildren()) {
			control.setEnabled(false);
		}
		
		cancelBtn = new Button(shell, SWT.PUSH);
		cancelBtn.setText("Cancel");
		GridData cancelData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
		cancelData.widthHint = 76;
		cancelBtn.setLayoutData(cancelData);
		
		useAuthoBtn = new Button(shell, SWT.CHECK);
		useAuthoBtn.setText("Authorization");
		GridData authoData = new GridData(SWT.CENTER, SWT.CENTER, false, false);		
		useAuthoBtn.setLayoutData(authoData);		
	}
	
	public Shell shell;
	public Display display;
	public Label address;
	public Text addressInput;
	public Button acceptBtn;
	public Button cancelBtn;
	public Button useAuthoBtn;
	public Group authoGroupBox;
	public Text loginInput;
	public Text passwdInput;
}